package com.matt.foundation.vo.evaluate;

import com.matt.domain.Children;
import com.matt.foundation.utils.DateUtil;
import com.matt.foundation.vo.IDCountDateVO;
import com.tuo51.evaluate.domain.evaluatingV2.EvaluateV2Record;
import lombok.Data;

import java.util.Date;
import java.util.List;
import java.util.Objects;

//import com.matt.domain.evaluatingV2.EvaluateV2Record;

@Data
public class EvaluateChildrenVO {
    private String childrenId;
    private String name;
    private String imgUrl;
    private Integer gender;
    private Integer month;

    private Integer evaluateTimes=0;
    private Long intervalDay=0L;

//    public static EvaluateChildrenVO of(Children children, List<EvaluateRecord> recordList) {
//        EvaluateChildrenVO vo = new EvaluateChildrenVO();
//        vo.setChildrenId(children.getId());
//        vo.setName(children.getName());
//        vo.setImgUrl(children.getImgUrl());
//        vo.setGender(children.getGender());
//        vo.setMonth(DateUtil.betweenMonths(new Date(), children.getBirthday()));
//        if (Objects.nonNull(recordList) && recordList.size()!=0){
//            vo.setEvaluateTimes(recordList.size());
//            vo.setIntervalDay(DateUtil.betweenDays(recordList.get(0).getCreated(), new Date()));
//        }
//        return vo;
//    }


    public static EvaluateChildrenVO of(Children children, IDCountDateVO countDateVO) {
        EvaluateChildrenVO vo = new EvaluateChildrenVO();
        vo.setChildrenId(children.getId());
        vo.setName(children.getName());
        vo.setImgUrl(children.getImgUrl());
        vo.setGender(children.getGender());
        vo.setMonth(DateUtil.betweenMonths(new Date(), children.getBirthday()));

        if (countDateVO != null && countDateVO.getCount().intValue() > 0){
            vo.setEvaluateTimes(countDateVO.getCount().intValue());
            vo.setIntervalDay(DateUtil.betweenDays(countDateVO.getDate(), new Date()));
        }

        return vo;
    }

    public static EvaluateChildrenVO ofV2(Children children, List<EvaluateV2Record> recordList) {
        EvaluateChildrenVO vo = new EvaluateChildrenVO();
        vo.setChildrenId(children.getId());
        vo.setName(children.getName());
        vo.setImgUrl(children.getImgUrl());
        vo.setGender(children.getGender());
        vo.setMonth(DateUtil.betweenMonths(new Date(), children.getBirthday()));
        if (Objects.nonNull(recordList) && recordList.size()!=0){
            vo.setEvaluateTimes(recordList.size());
            vo.setIntervalDay(DateUtil.betweenDays(recordList.get(0).getCreated(), new Date()));
        }
        return vo;
    }
}
